import {MessageType} from "./MessageType"
import {Action} from "../../configuration/ActionCreator"
import {hasString} from "../../util/TextCheck/TextCheck"



export const DisplayWarnMessage = 'DisplayWarnMessage';
export const doDisplayWarnMessage = (message) => Action(DisplayWarnMessage, {message});

export const DisplaySuccessMessage = 'DisplaySuccessMessage';
export const doDisplaySuccessMessage = (message) => Action(DisplaySuccessMessage, {message});

export const RemoveMessage = 'RemoveMessage';
export const doRemoveMessage = () => Action(RemoveMessage);

export const doShowMessage = (message, {alertWithType}) => {

  if (hasString(message.message)) {
    switch (message.messageType) {
      case MessageType.Warning: {
        alertWithType('warn', '提示', message.message);
        break;
      }
      case MessageType.Success: {
        alertWithType('success', '恭喜', message.message);
        break;

      }
    }
  }

};